<?php
/**
 * Created by PhpStorm.
 * User: W
 * Date: 2018/12/21
 * Time: 10:28
 */

namespace app\sports_admin\model;



use think\Model;
use think\Request;

class Dissertation extends Model
{
    protected $table = "dissertation";
    protected $pk    = "id";
    public static function showListAll($page,$rows,$sort,$sortOrder,$searchName)
    {
        $adminList = self::
            where(function($query)use($searchName){
                if($searchName){
                    $query->where('title','like',"%{$searchName}%");
                }})
            ->page($page)
            ->limit($rows)
            ->order("{$sort}","{$sortOrder}")->select();

        $adminCount = self::
            where(function($query)use($searchName){
            if($searchName){
                $query->where('title','like',"%{$searchName}%");
            }})
            ->count();
        return ['rows'=>$adminList,'total'=>$adminCount];
    }
    //添加论文
    public static function add()
    {
        $data = Request::instance()->only("title,content,author,url");
        return self::insert(['title'=>$data['title'],"content"=>$data['content'],"author"=>$data['author'],"url"=>$data['url']]);
    }
    //修改论文
    public static function upContent()
    {
        $data = Request::instance()->only("id,title,content,url,author");
        return self::where("id",$data['id'])->update(["title"=>$data['title'],"content"=>$data['content'],"url"=>$data['url'],"author"=>$data['author']]);
    }




}